﻿function ClientAddRoleForOffice()
{
    Url=Portal.SystemWebParts.RoleForOffice.RoleForOffice.GetAddGroupNewUrl().value;
    window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;'); 
    RealJumpPageRoleForOffice();
}

function ClientSaveAddRoleForOffice()
{
    Subject = document.getElementById("txtRoleForOffice").value;
    OfficeCode = document.getElementById("txtOfficeCode").value;
    RetValue = Portal.SystemWebParts.RoleForOffice.AddRoleForOffice.ServerSideAddRoleForOffice(OfficeCode,Subject).value;
    if(RetValue.indexOf("ERROR")!=-1)
    {
        alert(RetValue);
        return;
    }
    alert(RetValue);
    window.close();
}

function ClientDeleteRoleForOffice(RoleForOfficeId)
{
    Msg=Portal.SystemWebParts.RoleForOffice.RoleForOffice.GetConfirmDeleteMsg().value;
    if(confirm(Msg)==false)return;
    RetValue = Portal.SystemWebParts.RoleForOffice.RoleForOffice.ServerSideDeleteRoleForOffice(RoleForOfficeId).value;
    if(RetValue.indexOf("ERROR")!=-1)
    {
        alert(RetValue);
        return;
    }
    alert(RetValue);
    RealJumpPageRoleForOffice();
}

function ShowClientUpdateUrlForm(RoleForOfficeId)
{
    Url=Portal.SystemWebParts.RoleForOffice.RoleForOffice.GetShowUpdateForm(RoleForOfficeId).value;
    if(Url.indexOf("ERROR")!=-1)
    {
        alert(Url);
        return;
    }
    window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;'); 
    RealJumpPageRoleForOffice();
}


function ShowFormRoleForOfficeInUser(RoleForOfficeId)
{
    Url=Portal.SystemWebParts.RoleForOffice.RoleForOffice.GetShowFormRoleForOfficeInUser(RoleForOfficeId).value;
    if(Url.indexOf("ERROR")!=-1)
    {
        alert(Url);
        return;
    }
    window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;'); 
    RealJumpPageRoleForOffice();
}

function ClientSaveUpdateRoleForOffice(RoleForOfficeId)
{
    Subject=document.getElementById("txtRoleForOffice").value;
    RetValue = Portal.SystemWebParts.RoleForOffice.UpdateRoleForOffice.ServerSideUpdateRoleForOffice(RoleForOfficeId,Subject).value;
    if(RetValue.indexOf("ERROR")!=-1)
    {
        alert(RetValue);
        return;
    }
    alert(RetValue);
    window.close();
}


function ShowClientRoleForOfficeItemUrlForm(RoleForOfficeId)
{
    Url=Portal.SystemWebParts.RoleForOffice.RoleForOffice.GetShowRoleForOfficeItemsForm(RoleForOfficeId).value;
    if(Url.indexOf("ERROR")!=-1)
    {
        alert(Url);
        return;
    }
    window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;'); 
}

function ClientShowNewsItemForms(RoleForOfficeId)
{
    Url=Portal.SystemWebParts.RoleForOffice.RoleForOffice.GetShowNewsItemForm(RoleForOfficeId).value;
    if(Url.indexOf("ERROR")!=-1)
    {
        alert(Url);
        return;
    }
    window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;'); 
}



function JumPageAvailableRoleForOffice(RoleForOfficeId)
{
    document.getElementById("divProcessingAvailable").innerHTML=Portal.SystemWebParts.RoleForOffice.RoleForOfficeInUser.GetProcessingText().value;
    setTimeout("RealJumPageAvailableRoleForOffice('"+RoleForOfficeId+"')",10);
}

function RealJumPageAvailableRoleForOffice(RoleForOfficeId)
{
    PageIndex=0;
    if(document.getElementById("divSelectAvailableRoleForOffice")!=null)
    {   
        PageIndex=document.getElementById("divSelectAvailableRoleForOffice").selectedIndex;
    }
    Keyword=document.getElementById("txtAvailableKeyword").value;
    retValue=Portal.SystemWebParts.RoleForOffice.RoleForOfficeInUser.ReadingAvailableUser(RoleForOfficeId,Keyword,PageIndex).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    document.getElementById("divProcessingAvailable").innerHTML="";
    document.getElementById("divAvailableRoleForOffice").innerHTML=retValue;
}







function JumPageAlreadyRoleForOffice(RoleForOfficeId)
{
    document.getElementById("divProcessingAlready").innerHTML=Portal.SystemWebParts.RoleForOffice.RoleForOfficeInUser.GetProcessingText().value;
    setTimeout("RealJumPageAlreadyRoleForOffice('"+RoleForOfficeId+"')",10);
}

function RealJumPageAlreadyRoleForOffice(RoleForOfficeId)
{
    PageIndex=0;
    if(document.getElementById("divSelectAlreadyRoleForOffice")!=null)
    {   
        PageIndex=document.getElementById("divSelectAlreadyRoleForOffice").selectedIndex;
    }
    Keyword=document.getElementById("txtAlreadyKeyword").value;
    retValue=Portal.SystemWebParts.RoleForOffice.RoleForOfficeInUser.ReadingAlreadyUser(RoleForOfficeId,Keyword,PageIndex).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    document.getElementById("divProcessingAlready").innerHTML="";
    document.getElementById("divAlreadyRoleForOffice").innerHTML=retValue;
}



function AssignUserToThisRoleForOffice(UserId,RoleForOfficeId)
{
    retValue=Portal.SystemWebParts.RoleForOffice.RoleForOfficeInUser.ServerSideAddUserToRoleForOffice(UserId,RoleForOfficeId).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    RealJumPageAvailableRoleForOffice(RoleForOfficeId);
    RealJumPageAlreadyRoleForOffice(RoleForOfficeId);
}


function RomoveUserFromThisRoleForOffice(UserId,RoleForOfficeId)
{
    if(confirm(Portal.SystemWebParts.RoleForOffice.RoleForOfficeInUser.GetConfirmDeleteMsg().value)==false)return;
    retValue=Portal.SystemWebParts.RoleForOffice.RoleForOfficeInUser.ServerSideRemoveUserFromRoleForOffice(UserId,RoleForOfficeId).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    RealJumPageAvailableRoleForOffice(RoleForOfficeId);
    RealJumPageAlreadyRoleForOffice(RoleForOfficeId);
}



function JumPageRoleForOffice()
{
    document.getElementById("divProcessing").innerHTML=Portal.SystemWebParts.RoleForOffice.RoleForOffice.GetProcessingText().value;
    setTimeout("RealJumpPageRoleForOffice()",10);
}

function RealJumpPageRoleForOffice()
{
    PageIndex=0;
    if(document.getElementById("divSelectPageRoleForOffice")!=null)
    {   
        PageIndex=document.getElementById("divSelectPageRoleForOffice").selectedIndex;
    }
    Keyword=document.getElementById("txtKeyword").value;
    retValue=Portal.SystemWebParts.RoleForOffice.RoleForOffice.GetHtml(Keyword,PageIndex).value;
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    document.getElementById("divProcessing").innerHTML="";
    document.getElementById("divRoleForOfficeMain").innerHTML=retValue;
}


function ShowImportFromAdFunc()
{
    Url=Portal.SystemWebParts.RoleForOffice.RoleForOffice.ServerSideShowImportFromAdFunc().value;
    if(Url.indexOf("ERROR")!=-1)
    {
        alert(Url);
        return;
    }
    window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;'); 
    RealJumpPageRoleForOffice();   
}



function ClientExecuteImport()
{
    document.getElementById("divProcessing").innerHTML=Portal.SystemWebParts.RoleForOffice.ImportRoleForOfficeFromAd.GetProcessingText().value;
    setTimeout("RealExecuteImport()",10);
}

function RealExecuteImport()
{
    retValue=Portal.SystemWebParts.RoleForOffice.ImportRoleForOfficeFromAd.ServerSideExecuteImport().value;
    document.getElementById("divProcessing").innerHTML="";
    if(retValue.indexOf("ERROR")!=-1)
    {
        alert(retValue);
        return;
    }
    document.getElementById("divLog").innerHTML=retValue;
}